package leetCode;

public class RectangleOverlap {

	public boolean isRectangleOverlap(int[] rec1, int[] rec2) {
		return !(helper(rec1, rec2) || helper(rec2, rec1));
	}

	/**
	 * 不相交
	 * 
	 * @param rec1
	 * @param rec2
	 * @return
	 */
	private boolean helper(int[] rec1, int[] rec2) {
		return rec2[3] <= rec1[1] || rec2[2] <= rec1[0];
	}

	public static void main(String[] args) {
		int[] rec1 = { 3, 8, 6, 20 }, rec2 = { 2, 17, 6, 20 };// { 5, 15, 8, 18 }, rec2 = { 0, 3, 7, 9 };
		// 3,8,6,20 2,17,6,20
		System.out.println(new RectangleOverlap().isRectangleOverlap(rec1, rec2));
	}

}
